﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

using PromotionApp.Utility;
using System.Data.SqlClient;
using System.Data;

namespace PromotionApp.DAL
{
    public class BaseDAL
    {
        #region Protected Variable

        protected SQLHelper _SQLHelper = null;

        #endregion

        #region Constructor

        public BaseDAL()
        {
            this._SQLHelper = new SQLHelper(ConfigurationHelper.ConnectionString); 
        }

        #endregion

        #region Public Method

        public SqlConnection GetConnection()
        {
            return this._SQLHelper.GetConnection();
        }

        public int GetTotalRow(string strSql)
        {
            List<SqlParameter> list = new List<SqlParameter>();
            int totalRow = Convert.ToInt32(this._SQLHelper.ExecuteScalar(strSql, list, CommandType.Text));

            return totalRow;
        }

        public DataSet GetDataSetFromSql(string strSql)
        {
            List<SqlParameter> list = new List<SqlParameter>();
            DataSet ds = this._SQLHelper.GetDataSet(strSql, list, CommandType.Text);

            return ds;
        }

        #endregion

    }
}